/**
 * Created by kangdaye on 16/6/5.
 */
app.controller('distrVipDetailDialogCtr',["$scope","$rootScope","ngDialog","getData","viewData","distrVipService", function($scope,$rootScope,ngDialog,getData,viewData,distrVipService) {
    $scope.detailData = {};
    $scope.viewData = viewData;

    distrVipService.detail(getData,function(data){
        $scope.detailData = data.data;
    });

    $scope.changeBalance = function(id,nickname){
    	ngDialog.closeAll();
        ngDialog.open({
            template: '/admin/view/vip/distrVip/distrVipChangeBalanceDialog.html',
            width: 400,
            controller: 'distrVipChangeBalanceDialogCtr',
            resolve: {
                getData: function() {
                    return {
                        id : id,
                        nickname:nickname
                    };
                }
            }
        });
    };
}]);
/**
 * Created by wk on 16/9/16.
 */
app.controller('distrVipChangeBalanceDialogCtr',["$scope","$rootScope","ngDialog","$http","getData","distrVipService", function($scope,$rootScope,ngDialog,$http,getData,distrVipService) {
    $scope.amount = "";
    $scope.reason = "";
    $scope.getData = getData;

    $scope.submit = function(){
       $http({
            method:'POST',
            url: servicePath +'/member/change_balance',
            cache: false,
            dataType: 'json',
            data:{
            	id:getData.id,
            	amount:parseFloat($scope.amount),
            	reason:$scope.reason
            }
        }).success(function(data, status) {
        	if(status==200){
        	 ngDialog.closeAll();	
        	}
        })
    };
    $scope.cancel = function(){
        ngDialog.closeAll();	
    };
}]);